<?php
header("Content-type:text/html; charset=utf-8");
require_once ('config.php');
require_once (WEBURL.'/include/conn.php');
require_once (WEBURL.'/login_status_check.php');
if(!isset($_POST['website'])){
	echo "forbidden!";
	exit();
}
if(!checkLogin()){
	   $gotopage=base64_encode("sys_information_set.php");
	   header("Location:admin_login.php?gotopage=".$gotopage);	
}
else{
	$ipfilter=$_POST['ipfilter'];
	$ipfilter=str_replace("\n", "",$ipfilter);
	$ipfilter=str_replace("\r", "",$ipfilter);
	$filename=WEBURL."/data/ipfilter/ipfilter.txt";
	file_put_contents($filename,$ipfilter);
	$website=$_POST['website'];
	$template=$_POST['template'];
	$index_model=basename($_POST['index_model']);
	$index_movie=basename($_POST['index_movie']);
	$search_model=basename($_POST['search_model']);
	mysql_query("set autocommit=0");
	$sql_update_website="update sysconfig set sysconfig_value='$website' where sysconfig_name='website'";
	$result_update_website=mysql_query($sql_update_website);
	$sql_update_sys_style="update sysconfig set sysconfig_value='$template' where sysconfig_name='sys_style'";
	$result_update_sys_style=mysql_query($sql_update_sys_style);
	$sql_update_index_model="update sysconfig set sysconfig_value='$index_model' where sysconfig_name='index_model'";
	$result_update_index_model=mysql_query($sql_update_index_model);
	$sql_update_index_movie="update sysconfig set sysconfig_value='$index_movie' where sysconfig_name='index_movie'";
	$result_update_index_movie=mysql_query($sql_update_index_movie);
	$sql_update_search_model="update sysconfig set sysconfig_value='$search_model' where sysconfig_name='search_model'";
	$result_update_search_model=mysql_query($sql_update_search_model);
	if(!$result_update_index_model||!$result_update_index_movie||!$result_update_sys_style||!$result_update_website||!$result_update_search_model){
		mysql_query("rollback");
	}else{
	mysql_query("commit");
	}
	
	mysql_query("set autocommit=1");
	echo "<script language=JavaScript> alert('设置成功！');window.location.href='sys_information_set.php';</script>";
	//echo $website.$template.$index_model.$page_status;
}